﻿using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using App.Authorization.Roles;
using App.BaseObject;
using App.Organizations;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System;

namespace App.Authorization.Users
{
    /// <summary>
    /// 用户
    /// </summary>
    public class User : AuditedEntity<long>, IMayHaveTenant, IPassivable
    {
        public const string DefaultUserName = "admin";

        [StringLength(ColumnSetting.Short)]
        public virtual string UserName { get; set; }
        public virtual string PasswordHash { get; set; }
        [StringLength(ColumnSetting.Longer)]
        public virtual string Email { get; set; }
        public virtual bool EmailConfirmed { get; set; }
        [StringLength(ColumnSetting.Phone)]
        public virtual string Mobile { get; set; }
        public virtual bool MobileConfirmed { get; set; }
        [ForeignKey("UserId")]
        public virtual ICollection<UserRole> Roles { get; set; }
        [ForeignKey("UserId")]
        public virtual ICollection<UserPermission> Permissions { get; set; }
        public virtual OrganizationUnit OrganizationUnit { get; set; }
        public virtual ICollection<LoginLog> LoginLogs { get; set; }

        public virtual int? TenantId { get; set; }

        public virtual bool IsActive { get; set; }
        public virtual DateTime? LastLoginTime { get; set; }
    }
}
